home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11308 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  69 lines

  1. Path: rcp6.elan.af.mil!rscernix!root
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: String Upper/Lower--void main an error?
  5. Date: 20 Mar 96 15:23:28 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <root.827335408@rscernix>
  8. References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net> <4ini70$8j@vodka.intele.net>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4ini70$8j@vodka.intele.net> cjmorgan@intele.net (Jason V. Morgan) writes:
  13.  
  14. >>>void main (void) {
  15. >>
  16. >>Oh, please!  Read the FAQ to avoid posting crap like this.
  17. >>
  18. >I don't thing that void main is really considered to be an error.
  19.  
  20. Nobody cares about what you think.  You were asked to read the FAQ
  21. _before_ emiting your (incompetent) opinions on this topic, which has
  22. been rehashed to death in this newsgroup.
  23.  
  24. >Return 
  25. >values are only really necessary if they're going to mean anything.  It is 
  26. >compilable (maybe I'm wrong and it's not portable). 
  27.  
  28. Yes, you _are_ wrong and it is "compilable" ONLY if your compiler decides
  29. to compile it, because it is not required to accept such garbage.  My
  30. compiler doesn't:
  31.  
  32.     AxCrnA$ copy void.c tt:
  33.     void main(void) {}
  34.     AxCrnA$ cc void.c
  35.  
  36.     void main(void) {}
  37.     .....^
  38.     %CC-E-NEEDNONVOID, In this statement, "main(...)" has void type, but occurs in a
  39.      context that requires a non-void result.
  40.     at line number 1 in file DISK$L32:[DANPOP]VOID.C;1
  41.  
  42. >At least it was declared 
  43. >void so it didn't default to an int. 
  44.  
  45. And this is precisely the mistake!  It is illegal to define main() as
  46. returning void.
  47.  
  48. >You might as well say that it's an error 
  49. >because argc, argv, and env weren't passed (to be honest, I'm not sure if env 
  50. >is actually standard, I got it from the programmer's reference, not the 
  51. >standard).
  52.  
  53. You're 100% ignorant as far as this problem is concerned.  argc and argv
  54. are _optional_ in the definition of main() and env has no business to be
  55. in the argument list of main().  Try to stick this in your head: the C
  56. language allows main() to have either two arguments (int and char**) or
  57. none.  It also _requires_ main() to be defined as a function returning int.
  58. Otherwise, your program invokes undefined behaviour, and the programmer's 
  59. reference for your compiler is completely irrelevant to this newsgroup.
  60. The C programming language is NOT defined by your compiler or its
  61. documentation.
  62.  
  63. Dan
  64. --
  65. Dan Pop
  66. CERN, CN Division
  67. Email: danpop@mail.cern.ch 
  68. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  69.